package reflect;

import annotations.AutoRunClass;
import annotations.AutoRunMethod;

/**
 * @author 老安
 * @data 2022/7/21 20:43
 * 使用当前的类测试反射机制
 */
@AutoRunClass
public class Person {
    private String name = "张三";
    private int age = 22;
    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void sayHello() {
        System.out.println(name + ":" + "hello!");
    }
    @AutoRunMethod
    public void sayHi() {
        System.out.println(name + ":" + "hi!");
    }
    @AutoRunMethod(5)
    public void sayGoodBye() {
        System.out.println(name + ":" + "bye!");
    }

    public void doSome(String thing) {
        System.out.println(name + "正在做:" + thing);
    }

    public void doSome(String thing, int sum) {
        for (int i = 0; i < sum; i++) {
            System.out.println(name + "正在第" + (i + 1) + "遍做:" + thing);
        }
    }

    private void secret() {
        System.out.println(name + ":这是我的小秘密!!!");
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
